<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>JSP</title>
    <%--<script src="//cdn.bootcss.com/jquery/3.1.0/jquery.js"></script>--%>
    <script src="/jquery-3.1.0.min.js"></script>
    <script>
        $(function () {
//            alert("Hello Jquery");
            $(".delete").click(function () {
//                alert($(this).attr("href"));
//                var href = $(this).attr("href");
//                $("form").attr("action",href).submit();
                $("form").attr("action",$(this).attr("href")).submit();
                return false;
            });

        })
    </script>
</head>
<body>
<%--private Integer id;--%>
<%--private String username;--%>
<%--private String password;--%>
<%--private String email;--%>
<%--private Integer age;--%>
<%--private Address address;--%>
    <form method="post" action="">
        <input type="hidden" name="_method" value="DELETE">
    </form>
    <c:if test="${empty requestScope.users}">
        <h1>没有数据</h1>
    </c:if>
    <c:if test="${!empty requestScope.users}">
        <table>
            <tr>
                <td>用户ID</td>
                <td>用户名</td>
                <td>密码</td>
                <td>email</td>
                <td>年龄</td>
                <td>省份</td>
                <td>修改</td>
                <td>删除</td>
            </tr>

        <c:forEach var="user" items="${requestScope.users}">
            <tr>
                <td>${user.id}</td>
                <td>${user.username}</td>
                <td>${user.password}</td>
                <td>${user.email}</td>
                <td>${user.age}</td>
                <td>${user.department.name}</td>
                <td><a href="/user/user/${user.id}">修改</a></td>
                <td><a class="delete" href="/user/user/${user.id}">删除</a></td>
            </tr>
        </c:forEach>
        </table>
    </c:if>
    <a href="/user/user">添加用户</a>
</body>
</html>
